package com.prdiot.poetry.controller;

import com.prdiot.poetry.domains.Tags;
import com.prdiot.poetry.service.ChengyuService;
import com.prdiot.poetry.service.MingjuService;
import com.prdiot.poetry.service.TagsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;

import javax.websocket.server.PathParam;
import java.util.List;

@Controller
public class TagsController {

    @Autowired
    TagsService tagsService;

    @Autowired
    MingjuService mingjuService;

    @Autowired
    ChengyuService chengyuService;

    @GetMapping("/tags")
    public String tags(Model model){
        model.addAttribute("tagList", tagsService.getTagsOrderByPoemCount());
        model.addAttribute("themeList",mingjuService.getMingjuTheme());
        model.addAttribute("mingjuList",mingjuService.getRandMingju());
        model.addAttribute("chengyuList",chengyuService.getRandPoetry());
        return "tags";
    }

}
